#include "ThreadPool.hpp"
#include "Task.hpp"
#include <iostream>
#include <vector>
#include <functional>
#include <unistd.h>
#include <ctime>
#include <memory>


int main()
{
    srand(time(nullptr) ^ getpid() ^ pthread_self());
    // 开启日志
    EnableScreen();

    // 定义智能指针
    // std::unique_ptr<ThreadPool<int>> tp(new ThreadPool<int>());
    std::unique_ptr<ThreadPool<Task>> tp = std::make_unique<ThreadPool<Task>>(5);

    tp->InitThreadPool();
    tp->Start();

    int tasknum = 10;
    while(tasknum)
    {  
        int a = rand() % 10 + 1;
        usleep(1234);
        int b = rand() % 5 + 1;
        Task t(a,b);
        LOG(INFO, "main thread push task : %s", t.DebugToString().c_str());
        tp->Enqueue(t);
        sleep(1);
        tasknum--;        
    }

    tp->Stop();
    tp->Wait();

    // Test(3, 11, 22, 33);
    // LOG(DEBUG, "helloworld: %s", "world");
    // LOG(DEBUG, "helloworld: %s, %d", "world", 1000);
    // LOG(DEBUG, "helloworld: %s, %d, %f", "world", 19, 28.89);
    
    // LogMessage( __FILE__, __LINE__, DEBUG, "helloworld: %s", "world");
    // LogMessage( __FILE__, __LINE__, DEBUG, "helloworld: %s, %d", "world", 1000);
    // LogMessage( __FILE__, __LINE__, DEBUG, "helloworld: %s, %d, %f", "world", 19, 28.89);
    // LogMessage( __FILE__, __LINE__, DEBUG, "helloworld");
    // LogMessage( __FILE__, __LINE__, DEBUG, "helloworld");
    // LogMessage( __FILE__, __LINE__, DEBUG, "helloworld");

    return 0;
}
